package com.ruoyi.service.score.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.service.score.entity.LaborScoreDetailEntity;
import com.ruoyi.service.score.mapper.LaborScoreDetailMapper;
import com.ruoyi.service.score.service.LaborScoreDetailService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户评分明细表 服务实现类
 * </p>
 *
 * @author Zane
 * @since 2025-10-14
 */
@Service
public class LaborScoreDetailServiceImpl extends
    ServiceImpl<LaborScoreDetailMapper, LaborScoreDetailEntity>
    implements LaborScoreDetailService {

  @Override
  public long countRated(Long laborId, String projectId, Long userId) {
    return count(queryWrapper().eq(LaborScoreDetailEntity::getProjectId, projectId)
        .eq(LaborScoreDetailEntity::getProjectLaborId, laborId)
        .eq(LaborScoreDetailEntity::getCreateBy, userId)
    );
  }

  @Override
  public Integer getAvgScore(Long scoreId) {
    return this.baseMapper.getAvgScore(scoreId);
  }

  private LambdaQueryWrapper<LaborScoreDetailEntity> queryWrapper() {
    return new LambdaQueryWrapper<>();
  }
}
